package com.huacloud.rocketmq;

import org.apache.log4j.Logger;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Created by terrytan on 2017-6-18.
 */
public class ConsumerMain {

    private static Logger log = Logger.getLogger(ConsumerMain.class);

    public static void main(String[] args) {
        String mqGroupName = "GroupTest1";
        String mqNamesrvIp = "127.0.0.1";
        String mqNamesrvPort = "9876";
        String mqConsumerInstance = "Consumer_instances_1";
        String mqTopicName = "TopicTest1";
        String mqTagName = "TageTest";

        try {
            InputStream io = ConsumerMain.class.getResourceAsStream("/MQConsumerConfig.properties");
            Properties prop = Properties.class.newInstance();
            prop.load(io);
            mqGroupName = prop.getProperty("MQ_PRODUCER_GROUP_NAME");
            //log.info(mqGroupName);
            mqNamesrvIp = prop.getProperty("MQ_NAMESRV_IP");
            //log.info(mqNamesrvIp);
            mqNamesrvPort = prop.getProperty("MQ_NAMESRV_PORT");
            //log.info(mqNamesrvPort);
            mqConsumerInstance = prop.getProperty("MQ_CONSUMER_INSTANCE");
            mqTopicName = prop.getProperty("MQ_TOPIC_NAME");
            mqTagName = prop.getProperty("MQ_TAG_NAME");


        } catch (IOException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

        NomConsumer nc = new NomConsumer(mqGroupName, mqNamesrvIp, mqNamesrvPort, mqConsumerInstance, mqTopicName, mqTagName);
        nc.consumeMSG();

    }
}
